function opts = getTrainingOptions(hyperparam,imds_validation)

if isempty(imds_validation) % if there is no validation set
opts = trainingOptions('adam',...
    'InitialLearnRate',hyperparam.InitialLearnRate,...
    'L2Regularization',hyperparam.L2Regularization,... 		
    'MiniBatchSize',hyperparam.MiniBatchSize,...			
    'MaxEpochs',hyperparam.MaxEpochs,...			
    'ExecutionEnvironment',hyperparam.ExecutionEnvironment,...
    'VerboseFrequency',50,...
    'Plots','training-progress');   
else  % if there is a validation set
opts = trainingOptions('adam',...
    'InitialLearnRate',hyperparam.InitialLearnRate,...
    'ValidationData',imds_validation,...		
    'ValidationFrequency',hyperparam.ValidationFrequency,...
    'ValidationPatience',hyperparam.ValidationPatience,...
    'L2Regularization',hyperparam.L2Regularization,... 		
    'MiniBatchSize',hyperparam.MiniBatchSize,...			
    'MaxEpochs',hyperparam.MaxEpochs,...				
    'ExecutionEnvironment',hyperparam.ExecutionEnvironment,...
    'VerboseFrequency',50,...
    'Plots','training-progress');
end

end
